package com.itheima.tilas.config;

import com.itheima.tilas.interceptor.LoginInterceptor;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * spring 配置类 : 一般用来配置拦截器,跨域配置等等配置
 * @Configuration 是配置类特化的注解 组合了@component
 * @author 132
 */
//@Configuration
//public class WebMvcConfiguration extends WebMvcConfigurationSupport {
public class WebMvcConfiguration implements WebMvcConfigurer {
    @Resource
    LoginInterceptor loginInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //添加拦截器
        registry.addInterceptor(loginInterceptor)
                //添加拦截路径
                .addPathPatterns("/**")
                //排除登录路径
                .excludePathPatterns("/login","/yml");
    }
}
